#include "MenuState.h";

#include "../Managers/GameService.h"
#include "../Managers/WindowManager.h"
#include "../Managers/StateManager.h"

//-------------------------------------------------------------------------------------------
MenuState::MenuState()
{	
}

//-------------------------------------------------------------------------------------------
MenuState::~MenuState()
{
}

//-------------------------------------------------------------------------------------------
 void MenuState::Begin()
{
	m_pStateManager = GameService::GetInstance()->GetStateManager();
}

//-------------------------------------------------------------------------------------------
void MenuState::End()
{
}

//-------------------------------------------------------------------------------------------
void MenuState::Tick(float DeltaTime)
{
 	WindowManager* pWindowManager = GameService::GetInstance()->GetWindowManager();
	sf::RenderWindow* pWindow = pWindowManager->GetWindow();

	sf::Text text("This is the Main Menu!\n Press Space to go to Playing State.\n Press Esc to Quit");
	int X = (pWindowManager->GetWidth() / 2) - 200;
	int Y = (pWindowManager->GetHeight() / 2);
	text.setPosition(X, Y);
	pWindow->draw(text);
}

//-------------------------------------------------------------------------------------------
void MenuState::OnInput(sf::Event::KeyEvent* pKeyEvent, bool keyDown)
{
	switch (pKeyEvent->code)
	{
	case sf::Keyboard::Space:
		{
			if (!keyDown)
				m_pStateManager->SetState(StateManager::GameStates::STATE_PLAYING);
		}break;

	case sf::Keyboard::Escape:
		{
			if (!keyDown)
				GameService::GetInstance()->Quit();
		}break;

	}
}